﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FunctionalLayer
{
    /// <summary>
    /// This class is used to calculate a checksum
    /// </summary>
    public static class CRC
    {
        /// <summary>
        /// Gets the checksum of the data
        /// </summary>
        /// <param name="data">data</param>
        /// <param name="size">size of data</param>
        /// <returns>Checksum value</returns>
        public static byte getChecksum(byte[] data, int size)
        {
            byte checksum = 0;
            for (int i = 0; i < size; i++)
            {
                checksum += data[i];
            }
            return (byte)(-checksum);
        }
    }
}
